/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import DAO.ProductDAO;
import DAO.ProductcatDAO;
import POJO.Product;
import POJO.Productcat;
import Util.GuiUtil;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Nguyen Hong Phu (1142066) - 11HCB (HCMUS)
 */
public class FrmStatusSale extends javax.swing.JInternalFrame {

    private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(this.getClass().getName());
    
    public FrmStatusSale() {
        initComponents();
        tbBanChay.setModel(new ProductStatusModelTable(new ArrayList()));
        tbHetHang.setModel(new ProductStatusModelTable(new ArrayList()));
        tbTonKho.setModel(new ProductStatusModelTable(new ArrayList()));
        tbSapHetHang.setModel(new ProductStatusModelTable(new ArrayList()));
        tbChuaNhapHang.setModel(new ProductStatusModelTable(new ArrayList()));
        formLoad();
    }
    private void formLoad(){
        int storeId = 1;
        try {
            List<Productcat> list = ProductcatDAO.getListProductCats(storeId);
            GuiUtil.addListCombobox(cboDMTonKho, list, "getName");
            GuiUtil.addListCombobox(cboDMBanChay, list, "getName");
            GuiUtil.addListCombobox(cboDMHetHang, list, "getName");
            GuiUtil.addListCombobox(cboDMChuaNhapHang, list, "getName");
            GuiUtil.addListCombobox(cboDMSapHetHang, list, "getName");
        } catch (Exception ex) {
           log.error(ex.getMessage(), ex.fillInStackTrace());
        }
        
    }
    private ProductStatusModelTable getModelTableBanChay(){
        return (ProductStatusModelTable) tbBanChay.getModel();
    }
    private ProductStatusModelTable getModelTableTonKho(){
        return (ProductStatusModelTable) tbTonKho.getModel();
    }
    private ProductStatusModelTable getModelTableHetHang(){
        return (ProductStatusModelTable) tbHetHang.getModel();
    }
    private ProductStatusModelTable getModelTableSapHetHang(){
        return (ProductStatusModelTable) tbSapHetHang.getModel();
    }
    private ProductStatusModelTable getModelTableChuaNhapHang(){
        return (ProductStatusModelTable) tbChuaNhapHang.getModel();
    }
    
    private void loadTableBanChay(Productcat c){
        try {
            List<Product> list = ProductDAO.getListHotProducts(c);
            getModelTableBanChay().setList(list);
        } catch (Exception ex) {
            log.error(ex.getMessage(),ex.fillInStackTrace());
        }
    }
    
    private void loadTableTonKho(Productcat c){
        try {
            List<Product> list = ProductDAO.getListInventoryProducts(c);
            getModelTableTonKho().setList(list);
        } catch (Exception ex) {
            log.error(ex.getMessage(),ex.fillInStackTrace());
        }
    }
    private void loadTableHetHang(Productcat c){
        try {
            List<Product> list = ProductDAO.getListSoldOutProducts(c);
            getModelTableHetHang().setList(list);
        } catch (Exception ex) {
            log.error(ex.getMessage(),ex.fillInStackTrace());
        }
    }
     private void loadTableSapHetHang(Productcat c){
        try {
            List<Product> list = ProductDAO.getListNearlySoldOutProducts(c);
            getModelTableSapHetHang().setList(list);
        } catch (Exception ex) {
            log.error(ex.getMessage(),ex.fillInStackTrace());
        }
    }
    private void loadTableChuaNhapHang(Productcat c){
        try {
            List<Product> list = ProductDAO.getListNotWarehouseProducts(c);
            getModelTableChuaNhapHang().setList(list);
        } catch (Exception ex) {
            log.error(ex.getMessage(),ex.fillInStackTrace());
        }
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbed = new javax.swing.JTabbedPane();
        jPanelBanChay = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbBanChay = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        cboDMBanChay = new javax.swing.JComboBox();
        jPanelTonKho = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbTonKho = new javax.swing.JTable();
        cboDMTonKho = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jPanelSapHetHang = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tbSapHetHang = new javax.swing.JTable();
        cboDMSapHetHang = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jPanelHetHang = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tbHetHang = new javax.swing.JTable();
        cboDMHetHang = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jPanelChuaNhapHang = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tbChuaNhapHang = new javax.swing.JTable();
        cboDMChuaNhapHang = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();

        setTitle("Tình trạng bán hàng");

        jTabbed.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedStateChanged(evt);
            }
        });

        tbBanChay.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tbBanChay);

        jLabel1.setText("Danh mục:");

        cboDMBanChay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboDMBanChay.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboDMBanChayItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanelBanChayLayout = new javax.swing.GroupLayout(jPanelBanChay);
        jPanelBanChay.setLayout(jPanelBanChayLayout);
        jPanelBanChayLayout.setHorizontalGroup(
            jPanelBanChayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
            .addGroup(jPanelBanChayLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cboDMBanChay, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelBanChayLayout.setVerticalGroup(
            jPanelBanChayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelBanChayLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelBanChayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cboDMBanChay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
        );

        jTabbed.addTab("Sản phẩm bán chạy", jPanelBanChay);

        tbTonKho.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tbTonKho);

        cboDMTonKho.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboDMTonKho.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboDMTonKhoItemStateChanged(evt);
            }
        });

        jLabel2.setText("Danh mục:");

        javax.swing.GroupLayout jPanelTonKhoLayout = new javax.swing.GroupLayout(jPanelTonKho);
        jPanelTonKho.setLayout(jPanelTonKhoLayout);
        jPanelTonKhoLayout.setHorizontalGroup(
            jPanelTonKhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
            .addGroup(jPanelTonKhoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cboDMTonKho, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelTonKhoLayout.setVerticalGroup(
            jPanelTonKhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTonKhoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTonKhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(cboDMTonKho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
        );

        jTabbed.addTab("Sản phẩm tồn kho", jPanelTonKho);

        tbSapHetHang.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane5.setViewportView(tbSapHetHang);

        cboDMSapHetHang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboDMSapHetHang.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboDMSapHetHangItemStateChanged(evt);
            }
        });

        jLabel4.setText("Danh mục:");

        javax.swing.GroupLayout jPanelSapHetHangLayout = new javax.swing.GroupLayout(jPanelSapHetHang);
        jPanelSapHetHang.setLayout(jPanelSapHetHangLayout);
        jPanelSapHetHangLayout.setHorizontalGroup(
            jPanelSapHetHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
            .addGroup(jPanelSapHetHangLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cboDMSapHetHang, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelSapHetHangLayout.setVerticalGroup(
            jPanelSapHetHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelSapHetHangLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelSapHetHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cboDMSapHetHang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
        );

        jTabbed.addTab("Sản phẩm sắp hết hàng", jPanelSapHetHang);

        tbHetHang.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane4.setViewportView(tbHetHang);

        cboDMHetHang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboDMHetHang.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboDMHetHangItemStateChanged(evt);
            }
        });

        jLabel3.setText("Danh mục:");

        javax.swing.GroupLayout jPanelHetHangLayout = new javax.swing.GroupLayout(jPanelHetHang);
        jPanelHetHang.setLayout(jPanelHetHangLayout);
        jPanelHetHangLayout.setHorizontalGroup(
            jPanelHetHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
            .addGroup(jPanelHetHangLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cboDMHetHang, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelHetHangLayout.setVerticalGroup(
            jPanelHetHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelHetHangLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelHetHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(cboDMHetHang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
        );

        jTabbed.addTab("Sản phẩm hết hàng", jPanelHetHang);

        tbChuaNhapHang.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane6.setViewportView(tbChuaNhapHang);

        cboDMChuaNhapHang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboDMChuaNhapHang.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboDMChuaNhapHangItemStateChanged(evt);
            }
        });

        jLabel5.setText("Danh mục:");

        javax.swing.GroupLayout jPanelChuaNhapHangLayout = new javax.swing.GroupLayout(jPanelChuaNhapHang);
        jPanelChuaNhapHang.setLayout(jPanelChuaNhapHangLayout);
        jPanelChuaNhapHangLayout.setHorizontalGroup(
            jPanelChuaNhapHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
            .addGroup(jPanelChuaNhapHangLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cboDMChuaNhapHang, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelChuaNhapHangLayout.setVerticalGroup(
            jPanelChuaNhapHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelChuaNhapHangLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelChuaNhapHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(cboDMChuaNhapHang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
        );

        jTabbed.addTab("Sản phẩm chưa nhập", jPanelChuaNhapHang);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbed, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbed, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTabbedStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedStateChanged
        if(jPanelBanChay.isShowing()){
           // loadTableBanChay();
        }else if(jPanelHetHang.isShowing()){
          // loadTableHetHang();
        }else if(jPanelTonKho.isShowing()){
          //  loadTableTonKho();
        }
    }//GEN-LAST:event_jTabbedStateChanged

    private void cboDMBanChayItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDMBanChayItemStateChanged
        if(evt.getStateChange() == ItemEvent.SELECTED)
             loadTableBanChay((Productcat)evt.getItem());
    }//GEN-LAST:event_cboDMBanChayItemStateChanged

    private void cboDMTonKhoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDMTonKhoItemStateChanged
         if(evt.getStateChange() == ItemEvent.SELECTED)
                loadTableTonKho((Productcat)evt.getItem());
    }//GEN-LAST:event_cboDMTonKhoItemStateChanged

    private void cboDMHetHangItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDMHetHangItemStateChanged
         if(evt.getStateChange() == ItemEvent.SELECTED)
                loadTableHetHang((Productcat)evt.getItem());
    }//GEN-LAST:event_cboDMHetHangItemStateChanged

    private void cboDMSapHetHangItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDMSapHetHangItemStateChanged
        if(evt.getStateChange() == ItemEvent.SELECTED)
                loadTableSapHetHang((Productcat)evt.getItem());
    }//GEN-LAST:event_cboDMSapHetHangItemStateChanged

    private void cboDMChuaNhapHangItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDMChuaNhapHangItemStateChanged
        if(evt.getStateChange() == ItemEvent.SELECTED)
                loadTableChuaNhapHang((Productcat)evt.getItem());
    }//GEN-LAST:event_cboDMChuaNhapHangItemStateChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cboDMBanChay;
    private javax.swing.JComboBox cboDMChuaNhapHang;
    private javax.swing.JComboBox cboDMHetHang;
    private javax.swing.JComboBox cboDMSapHetHang;
    private javax.swing.JComboBox cboDMTonKho;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanelBanChay;
    private javax.swing.JPanel jPanelChuaNhapHang;
    private javax.swing.JPanel jPanelHetHang;
    private javax.swing.JPanel jPanelSapHetHang;
    private javax.swing.JPanel jPanelTonKho;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbed;
    private javax.swing.JTable tbBanChay;
    private javax.swing.JTable tbChuaNhapHang;
    private javax.swing.JTable tbHetHang;
    private javax.swing.JTable tbSapHetHang;
    private javax.swing.JTable tbTonKho;
    // End of variables declaration//GEN-END:variables
}



//<editor-fold defaultstate="collapsed" desc="Product model table">
class ProductStatusModelTable extends AbstractTableModel {

    private static final String[] columnNames = {"Mã sản phẩm", "Tên sản phẩm","Danh mục","Số lượng",
                                                "Số lượng bán", "Số lượng tồn"};
    private List<Product> list;

    public ProductStatusModelTable(List<Product> list) {
        this.list = list;
    }

    public List<Product> getList() {
        return this.list;
    }
    public Product getItem(int rowIndex){
        return this.list.get(rowIndex);
    }
    public void setList(List<Product> list) {
        this.list = list;
        fireTableDataChanged();
    }

    public void removeAllElement() {
        this.list.clear();
        fireTableDataChanged();
    }

    public void addElement(Product e) {
        // Adds the element in the last position in the list
        list.add(e);
        fireTableRowsInserted(list.size() - 1, list.size() - 1);
    }

    public void removeElement(int rowIndex) {
        list.remove(rowIndex);
        fireTableRowsDeleted(rowIndex, rowIndex);
    }

    @Override
    public int getRowCount() {
        return list.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public String getColumnName(int index) {
        return columnNames[index];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return list.get(rowIndex).getId();
            case 1:
                return list.get(rowIndex).getName();
            case 2:
                return list.get(rowIndex).getProductcat().getName();
            case 3:
                return list.get(rowIndex).getTotalinstock();
            case 4:
                return list.get(rowIndex).getTotalinstock() -
                            list.get(rowIndex).getQuantity();
            case 5:
                return list.get(rowIndex).getQuantity();
        }
        return null;
    }
}
//</editor-fold>
